/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author GiangLT
 */
@Entity
@Table(name = "MODULE_CONFIG", catalog = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ModuleConfig.findAll", query = "SELECT m FROM ModuleConfig m ORDER BY m.configId ASC"),
    @NamedQuery(name = "ModuleConfig.findByConfigId", query = "SELECT m FROM ModuleConfig m WHERE m.configId = :configId"),
    @NamedQuery(name = "ModuleConfig.findByModuleName", query = "SELECT m FROM ModuleConfig m WHERE m.moduleName = :moduleName ORDER BY m.configKey ASC"),
    @NamedQuery(name = "ModuleConfig.findByModuleAndKey", query = "SELECT m FROM ModuleConfig m WHERE m.moduleName = :moduleName and m.configKey = :configKey ORDER BY m.configKey ASC"),
    @NamedQuery(name = "ModuleConfig.getModuleNames", query = "SELECT DISTINCT m.moduleName FROM ModuleConfig m ORDER BY m.moduleName ASC"),
    @NamedQuery(name = "ModuleConfig.findByConfigKey", query = "SELECT m FROM ModuleConfig m WHERE m.configKey = :configKey"),
    @NamedQuery(name = "ModuleConfig.findByConfigValue", query = "SELECT m FROM ModuleConfig m WHERE m.configValue = :configValue"),
    @NamedQuery(name = "ModuleConfig.findByDescription", query = "SELECT m FROM ModuleConfig m WHERE m.description = :description")})
public class ModuleConfig implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "CONFIG_ID")
    private Long configId;
    @Size(max = 400)
    @Column(name = "MODULE_NAME")
    private String moduleName;
    @Size(max = 1000)
    @Column(name = "CONFIG_KEY")
    private String configKey;
    @Size(max = 1000)
    @Column(name = "CONFIG_VALUE")
    private String configValue;
    @Size(max = 1000)
    @Column(name = "DESCRIPTION")
    private String description;
    @OneToMany(mappedBy = "parentConfigId")
    private List<ModuleConfig> moduleConfigList;
    @JoinColumn(name = "PARENT_CONFIG_ID", referencedColumnName = "CONFIG_ID")
    @ManyToOne
    private ModuleConfig parentConfigId;

    public ModuleConfig() {
    }

    public ModuleConfig(Long configId) {
        this.configId = configId;
    }

    public Long getConfigId() {
        return configId;
    }

    public void setConfigId(Long configId) {
        this.configId = configId;
    }

    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public String getConfigKey() {
        return configKey;
    }

    public void setConfigKey(String configKey) {
        this.configKey = configKey;
    }

    public String getConfigValue() {
        return configValue;
    }

    public void setConfigValue(String configValue) {
        this.configValue = configValue;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public List<ModuleConfig> getModuleConfigList() {
        return moduleConfigList;
    }

    public void setModuleConfigList(List<ModuleConfig> moduleConfigList) {
        this.moduleConfigList = moduleConfigList;
    }

    public ModuleConfig getParentConfigId() {
        return parentConfigId;
    }

    public void setParentConfigId(ModuleConfig parentConfigId) {
        this.parentConfigId = parentConfigId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (configId != null ? configId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ModuleConfig)) {
            return false;
        }
        ModuleConfig other = (ModuleConfig) object;
        if ((this.configId == null && other.configId != null) || (this.configId != null && !this.configId.equals(other.configId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.thienloc.omap.entity.ModuleConfig[ configId=" + configId + " ]";
    }
    
}
